package com.boot.cluster.test;

import com.boot.cluster.worker.bean.TaskResponse;
import com.boot.cluster.worker.runner.Combiner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;


public class PiCombiner implements Combiner {
	private static Logger logger = LoggerFactory.getLogger(PiCombiner.class);

	@Override
	public <T> T action(List<TaskResponse> respList) {
		Double res = 0.0d;
		//respList.stream().mapToDouble(s -> (Double) s.getData()).sum();
		for (int i = 0; i < respList.size(); i++) {
			res += (Double) respList.get(i).getData();
		}
		res = res * 4;
		logger.info("res:" + res);
		return (T) res;
	}

}
